package generatedClasses;

import java.util.*;
import struts.*;
import struts.tools.*;

public class ContactCreator
{
  protected static String nl;
  public static synchronized ContactCreator create(String lineSeparator)
  {
    nl = lineSeparator;
    ContactCreator result = new ContactCreator();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "";
  protected final String TEXT_2 = NL;
  protected final String TEXT_3 = NL + "\t\tprivate String ";
  protected final String TEXT_4 = ";\t" + NL + "\t";
  protected final String TEXT_5 = NL + "\t" + NL + "\t";
  protected final String TEXT_6 = NL + "\t" + NL + "\t\tpublic String get";
  protected final String TEXT_7 = "(){" + NL + "\t\t\treturn ";
  protected final String TEXT_8 = ";" + NL + "\t\t}" + NL + "\t";
  protected final String TEXT_9 = NL + NL + "\t";
  protected final String TEXT_10 = NL + "\t\tpublic void set";
  protected final String TEXT_11 = "(String string){" + NL + "\t\t\t\t";
  protected final String TEXT_12 = "=string;" + NL + "\t\t}\t" + NL + "\t";
  protected final String TEXT_13 = NL + "\t\t\t" + NL + "\t" + NL + "}" + NL + NL;
  protected final String TEXT_14 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
     ArrayList<DataElement> formElts = (ArrayList<DataElement>) argument; 

    stringBuffer.append(TEXT_1);
    stringBuffer.append( "package struts.domain;" );
    stringBuffer.append(TEXT_2);
    stringBuffer.append( "public class Contact {" );
    	for(DataElement de:formElts){ 
    stringBuffer.append(TEXT_3);
    stringBuffer.append(de.getName().replaceAll("[ ]",""));
    stringBuffer.append(TEXT_4);
    }
    stringBuffer.append(TEXT_5);
    for(DataElement de:formElts){ 
    stringBuffer.append(TEXT_6);
    stringBuffer.append(de.getName().replaceAll("[ ]",""));
    stringBuffer.append(TEXT_7);
    stringBuffer.append(de.getName().replaceAll("[ ]",""));
    stringBuffer.append(TEXT_8);
    }
    stringBuffer.append(TEXT_9);
    for(DataElement de:formElts){ 
    stringBuffer.append(TEXT_10);
    stringBuffer.append(de.getName().replaceAll("[ ]",""));
    stringBuffer.append(TEXT_11);
    stringBuffer.append(de.getName().replaceAll("[ ]",""));
    stringBuffer.append(TEXT_12);
    }
    stringBuffer.append(TEXT_13);
    stringBuffer.append(TEXT_14);
    return stringBuffer.toString();
  }
}
